/**
 * 
 */
package database.datastructure;

/**
 * @author Sravan
 *
 */
public class BPlusTreeTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		test1();
	}

	public static void test1(){
		BPlusTree<Integer, String> tree = new BPlusTree<Integer, String>();

		String[] nums = {"zero", "one","two", "three", "four", "five", "six", "seven", "eight", "nine",
				"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
				"seventeen", "eighteen", "nineteen"}; 
		int i=0;
		for(String str:nums){
			//System.out.print(i+":");
			tree.insert(i++,str);
			/*for(int j=0; j<i; j++){
				System.out.print(tree.search(j)+",");
			}
			System.out.println();*/
		}
		tree.insert(19, "nineteen 1");
		tree.insert(19, "nineteen 2");
		tree.insert(19, "nineteen 3");
		tree.insert(19, "nineteen 4");
		tree.insert(19, "nineteen 5");
		tree.insert(19, "nineteen 6");
		tree.insert(19, "nineteen 7");
		tree.insert(19, "nineteen 8");
		tree.insert(19, "nineteen 9");
		tree.insert(19, "nineteen 10");
		System.out.println();
		//System.out.println(tree.search(2));
		System.out.println(tree.search(19));
		System.out.println(tree.printTree());
	}
	
	public static void test2(){
		BPlusTree<Integer, Integer> tree = new BPlusTree<Integer, Integer>();
		
		for(int i=0;i<1000;i++){
			System.out.print(i+":");
			tree.insert(i,1000-i);
			for(int j=0; j<=i & (i%10 == 0); j++){
				System.out.print(tree.search(j)+",");
			}
			System.out.println();
		}

		System.out.println(tree.search(1));
	}
	
	public static void test3(){
		BPlusTree<Integer, String> tree = new BPlusTree<Integer, String>();

		String[] nums = {"zero", "one","two", "three", "four", "five", "six", "seven", "eight", "nine",
				"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
				"seventeen", "eighteen", "nineteen"}; 
		int i=0;
		for(String str:nums){
			System.out.print(i+":");
			tree.insert(i++,str);
			for(int j=0; j<i; j++){
				System.out.print(tree.search(j)+",");
			}
			System.out.println();
		}
		tree.printRecordsOnBottomLevel_Forward();
	}
	
	public static void test4(){
		BPlusTree<Integer, String> tree = new BPlusTree<Integer, String>();

		String[] nums = {"zero", "one","two", "three", "four", "five", "six", "seven", "eight", "nine",
				"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
				"seventeen", "eighteen", "nineteen"}; 
		int i=0;
		for(String str:nums){
			System.out.print(i+":");
			tree.insert(i++,str);
			for(int j=0; j<i; j++){
				System.out.print(tree.search(j)+",");
			}
			System.out.println();
		}
		tree.printRecordsOnBottomLevel_Reverse();
	}

}
